const http = {};

http.ajax = function ({ type, url, data, success }) {

    const BASE_URL = 'http://localhost:8080/api/v1';

    const requestOption = {
        headers: { Authorization: window.localStorage.getItem('token') },
        type: type,
        url: BASE_URL + url,
        data: data,
        success: success,
        error: function (jqXHR) {
            if (jqXHR.status === 403) {
                parent.window.location.href = "./login.html";
            }
        }
    };

    const isFormData = data instanceof FormData;
    if (isFormData) {
        requestOption.contentType = false;
        requestOption.processData = false;
    }
    $.ajax(requestOption);
};